import asyncio


async def coroutine_example(name):
    print('开始任务：', name)
    await asyncio.sleep(1)
    print('执行完毕：', name)


loop = asyncio.get_event_loop()
tasks = [coroutine_example('task_' + str(i)) for i in range(3)]
# asyncio.wait()是一个协程，返回的是协程对象。传入的参数是future或协程构成的可迭代对象。最后将返回值传给run_until_complete()加入事件循环
wait_coro = asyncio.wait(tasks)
loop.run_until_complete(wait_coro)
loop.close()
